<template>
	<view>
		<view class="content">
			<view class="box" v-for="(item, index) in tableList">
				<view
					class="menuCard"
					@click="jumpSpotCheck(item.id, item.name)">
					<view class="title">
						{{ item.name }}
					</view>
				</view>
			</view>
		</view>
		<!-- 空数据 -->
		<view v-show="tableList.length === 0 && !tableLoading">
			<u-empty
				mode="list"
				icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
	onShow,
	onPullDownRefresh,
	onLoad,
	onBackPress,
} from "@dcloudio/uni-app";
import { http } from "@/utils/http";
import { PageResult, TabInfo } from "@/types/type";
import { getSecondTime } from "@/utils/common";
import { useDictionaryStore } from "@/stores/useDictionaryStore";

// 待完成数据
const tableList = ref([
	{
		id: "qmfi",
		name: "入厂检验",
	},
	{
		id: "qmpi",
		name: "生产检验",
	},
	{
		id: "qmfpi",
		name: "成品检验",
	},
]);
const tableLoading = ref(false);
const current = ref(0);
const totalPage = ref(0);
const total = ref(0);

//列表高度
const listHeight = ref("");
onLoad(() => {
	// #ifdef H5
	listHeight.value = "calc(100vh - 88px - 44px)";
	// #endif

	// #ifdef APP-PLUS
	listHeight.value = "calc(100vh - 48px - 44px)";
	// #endif
	// loadmore();
});
onPullDownRefresh(() => {
	searchList();
});
// 列表搜索
function searchList() {
	tableList.value = [];
	loadmore("refresh");
}
async function loadmore(type?: string) {
	const result: PageResult<any> = await http({
		method: "POST",
		url: "/eam/equPointInspection/getSopStandardList",
		data: {},
	});
	const list = result.data;
	for (let i = 0; i < list.length; i++) {
		tableList.value.push(list[i]);
	}
	type === "refresh" && uni.stopPullDownRefresh();
}
// 点击每一项点检标准
const jumpSpotCheck = (id, inspectionName) => {
	uni.navigateTo({
		url: `/pages/qms/qmsCheckList/qmsFactoryInspection?inspectionId=${id}&inspectionName=${inspectionName}&isRead=0`,
		fail: () => {
			uni.showToast({
				title: "敬请期待",
				icon: "error",
			});
		},
	});
};

onBackPress(() => {
	back1();
	return true;
});
const back1 = () => {
	uni.switchTab({
		url: "/pages/index/index",
	});
};
</script>

<style lang="scss" scoped>
uni-page-body {
	height: 100%;
	background-color: $primary-bg-color;
	padding: 10px;
}

.menuCard {
	// overflow: hidden;
	width: 600rpx;
	// background-color: #fff;
	border-radius: 16rpx;
	border: 1rpx solid rgba(0, 0, 0, 0.06);
	height: 220rpx;
	line-height: 180rpx;
	text-align: center;

	margin-bottom: 20rpx;
	background-image: -webkit-linear-gradient(
		180deg,
		#016ddc 0%,
		#2c92fb 53%,
		#33aaff 100%
	);
	// display: flex;
	:deep(.u-image) {
		margin: auto;
		// height: 120px;
		// display: flex;
		// flex: 1;
	}
	.title {
		// flex: 1;
		margin-top: 15rpx;
		// margin-bottom: 30rpx;
		color: #fff;
		font-size: 32rpx;
		font-weight: normal;
	}
}

.content {
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;
	flex-wrap: wrap;
	// margin: 0rpx 20rpx;
}

.title {
	font-size: 36rpx;
	color: #8f8f94;
}
</style>
